<?php
class cacheManageAction extends commonAction{
    //缓存列表
    function index(){
        $list=M('Cachemanage')->select();
        $this->assign("list",$list);
        $this->display();
    }
    //保存缓存设置
    function saveoptions(){
        if(!$this->isPost()){
            $this->error("非法提交");
        }
        $data=I('post.cache',array(),"");
        foreach ($data as $eachdata){
            if(M('Cachemanage')->create($eachdata)){
                if(M('Cachemanage')->save()===FALSE){
                    $this->error(M('Cachemanage')->getDbError());
                }
            }  else {
                $this->error(M('Cachemanage')->getError());
            }
        }
        $this->success("保存成功");
    }
    
    //清理缓存选项
    function clear(){
        $list = M('Cachemanage')->select();
        $this->assign("list", $list);
        $this->display();
    }
    
    //
    function clearcache($temp=""){
        if(preg_match('/[\.]/is',$temp)){
            $this->ajaxReturn(array("status"=>"0"));
        }
        $temp = empty($temp)?RUNTIME_PATH:RUNTIME_PATH.$temp;
        DelDirOrFile($temp);
        $this->ajaxReturn(array("status"=>"1"));
    }
    
}
